import request from '@/utils/request'
import { extendsObj } from '@/utils'

/**
 * 新增排版时段
 *
 * @export
 * @param {*} data { accountId, attendanceShiftId, carId, carPlatenumber, endPeriod, frequency, startPeriod, type }
 * @returns
 */

export function fetchAttendanceRecordAdd(data, options) {
  return request({
    url: '/attendanceRecord/add',
    method: 'post',
    data,
    ...options
  })
}

/**
 * 修改排版时段
 *
 * @export
 * @param {*} data { accountId, attendanceShiftId, carId, carPlatenumber, endPeriod, frequency, startPeriod, type, id }
 * @returns
 */

export function fetchAttendanceRecordUpdate(data, options) {
  return request({
    url: '/attendanceRecord/update',
    method: 'post',
    data,
    ...options
  })
}

/**
 * 删除排班
 *
 * @export
 * @param {*} data { id }
 * @returns
 */
export function fetchAttendanceRecordDelete(data, options) {
  return request({
    url: '/attendanceRecord/delete',
    method: 'post',
    data,
    ...options
  })
}

/**
 * 获取排班详情
 *
 * @export
 * @param {*} data { id }
 * @returns
 */
export function fetchAttendanceRecordGet(params, options) {
  return request({
    url: '/attendanceRecord/get',
    method: 'get',
    params,
    ...options
  })
}

/**
 * 获取排班列表
 *
 * @export
 * @param {*} data { beginDate, endDate, componentId, page, pagesize, type }
 * @returns
 */
export function fetchAttendanceRecordList(data, options) {
  const defaultQuery = {
    attendanceShiftId: 0,
    page: 1,
    pagesize: 10,
    name: '',
    beginDate: '',
    endDate: ''
  }
  return request({
    url: '/attendanceRecord/findPage',
    method: 'post',
    data: extendsObj(defaultQuery, data),
    ...options
  })
}
